package br.ucb.servlets;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.ucb.enumeradores.Sexo;
import br.ucb.service.Servicos;

/**
 * Servlet implementation class ObtemEstadosUser
 */
@WebServlet("/constantesuser")
public class ConstantesUser extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String pagina = null;
		RequestDispatcher disp;
		String acao = request.getParameter("acao");
		HttpSession sessao = request.getSession();
		if(acao.equals("alterar")) {
			sessao.setAttribute("estados", Servicos.obtemEstados());
			sessao.setAttribute("sexos", Sexo.MASCULINO);
			pagina = "alterarUser.jsp";
		} else if(acao.equals("cadastrar")) {
			request.setAttribute("estados", Servicos.obtemEstados());
			request.setAttribute("sexos", Sexo.MASCULINO);
			pagina = "cadastraUser.jsp";
		}
		disp = request.getRequestDispatcher(pagina);
		disp.forward(request, response);
	}


}
